﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _16_01_2013
{
    class MangMotChieu
    {
     
        static int i;
        static int[] a;
        static int temp = 0;
        public static void NhapLieuMang()
        {
            Console.Write("Nhap vao so chieu dai cua mang: ");
            int n = Convert.ToInt32(Console.ReadLine());
            a = new int[n];
            for (int i = 0; i < n; i++)
            {
                Console.Write("\n a[{0}]: ", i);
                a[i] = Convert.ToInt32(Console.ReadLine());
            }
        }
        public static void Sort()
        {
            for (int i = 0; i < a.Length; i++)
            {
                for (int j = i + 1; j < a.Length; j++)
                {
                    if (a[i] > a[j])
                    {
                        temp = a[i];
                        a[i] = a[j];
                        a[j] = temp;
                    }
                }
            }
        }
        public static bool KienTraSoNguyenTo(int number)
        {
            bool flag = true;//Gia su ban dau la so nguyen to
            for(int i=2;i<number/2;i++)
            {
                if(number%i==0)
                {
                    flag=false;
                    break;
                }
            }
            return flag;
        }
        public static void InSoNguyenToTrongMang()
        {
            for (i = 0; i < a.Length; i++)
            {
                if (KienTraSoNguyenTo(a[i]) == true)
                {
                    Console.WriteLine( "{0}", a[i]);
                }
            }
        }
        public static void XuatMang()
        {
            for (i = 0; i < a.Length; i++)
            {
                Console.Write("{0} ",a[i]);
            }
        }
    }
}
